﻿CREATE PROCEDURE [dbo].[proc_Finance_RunningAccount_GetItem]
	(
		@RId uniqueidentifier
	)
AS
begin
	Select
		R.Id,
		R.RId,
		R.CreateDate,
		R.TradeDate,
		R.Summary,
		R.AccountsTypeId,
		R.AccountsTypeName,
		R.ParentId,
		R.ParentName,
		R.SubjectId,
		R.SubjectName,
		R.PaymentTypeId,
		R.PaymentTypeName,
		R.BankId,
		R.BankName,
		R.Income,
		R.Outlay,
		Case When R.AccountsTypeId=1 Then R.Income Else R.Outlay End As  [Money],
		R.Agent,
		R.AgentName,
		R.UserName,
		R.EName,
		R.BillNumber,
		R.OrderId,
		R.Renling,
		R.Description,
		Isnull((Select CompanyName From Company Where Id=R.CompanyId),'...') As CompanyName,
		R.CompanyId
	From Finance_RunningAccount R Where R.RId=@RId
	
end
	RETURN
